using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
/** 所有窗口界面逻辑的基类，窗口必须指定一个名称为body的子控件 */
public class WindowView : View
{
    public override void Start()
    {
        base.Start();
        var closeButtonTransform = transform.GetChild(0).transform.Find("关闭按钮");
        if (closeButtonTransform != null)
        {
            var closeButton = closeButtonTransform.GetComponent<Button>();
            if (closeButton != null)
            {
                closeButton.onClick.AddListener(OnCloseButton);
            }
        }
        PlayOpenTween();
    }
    protected virtual void PlayOpenTween()
    {
        var rectTransform = transform.GetChild(0).GetComponent<RectTransform>();
        rectTransform.localScale = new Vector3(0.9f, 0.9f, 0.9f);
        rectTransform.DOScale(1f, 0.1f);
    }
    protected virtual void OnCloseButton()
    {
        Close();
    }
    public virtual void Close()
    {
        Destroy(gameObject);
    }
}